﻿using System.Linq;
using Enyim.Caching;
using Ayatta.Contract;
using System.Web.Mvc;
using Web.Manage.Controllers;
using Ayatta.Common.Extensions;
using Web.Manage.Areas.Sys.Models;

namespace Web.Manage.Areas.Sys.Controllers
{
    public class OAuthController : AdminBaseController
    {

        public OAuthController(ILogService logService, IBaseService baseService, IExtraService extraService, IStoreService storeService, IOrderService orderService, IGameService gameService, IAuctionService auctionService, IPassportService passportService, IPaymentService paymentService, IMemcachedClient memcachedClient)
            : base(logService, baseService, extraService, storeService, orderService, gameService, auctionService, passportService, paymentService, memcachedClient)
        {
        }

        public ActionResult Index(string name)
        {
            var model = new OAuthControllerModel.Index();
            var configs = PassportService.GetOAuthConfigs();
            model.Name = name;
            model.Configs = !name.IsNullOrEmpty() ? configs.Where(o => o.ClientName == name).ToList() : configs;
            return PartialView(model);
        }

        public ActionResult Detial(int param)
        {
            var model = PassportService.GetOAuthConfig(param);
            return PartialView(model);
        }
    }
}
